#include "stdafx.h"
#include "Settings.h"

LPCTSTR strRegKey = L"Software\\const.me\\TurnOffHdd";
LPCTSTR strRegValue = L"hdd";

HRESULT settingRead( CString& value )
{
	CRegKey key;
	LSTATUS ll = key.Create( HKEY_CURRENT_USER, strRegKey );
	if( ERROR_SUCCESS != ll )
		return HRESULT_FROM_WIN32( ll );
	ULONG nChars = 0;
	ll = key.QueryStringValue( strRegValue, NULL, &nChars );
	if( ERROR_SUCCESS != ll )
		return HRESULT_FROM_WIN32( ll );

	nChars++;
	TCHAR* buff = value.GetBufferSetLength( nChars );
	ll = key.QueryStringValue( strRegValue, buff, &nChars );
	value.ReleaseBuffer();

	if( ERROR_SUCCESS != ll )
		return HRESULT_FROM_WIN32( ll );

	return S_OK;
}

HRESULT settingWrite( LPCTSTR value )
{
	CRegKey key;
	LSTATUS ll = key.Create( HKEY_CURRENT_USER, strRegKey );
	if( ERROR_SUCCESS != ll )
		return HRESULT_FROM_WIN32( ll );

	ll = key.SetStringValue( strRegValue, value );
	if( ERROR_SUCCESS != ll )
		return HRESULT_FROM_WIN32( ll );

	return S_OK;
}